<!doctype html>
<html lang="zh-CH">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	{{--<meta name="viewport" content="width=device-width, initial-scale=1">--}}
	<title>央票通</title>
	<link rel="stylesheet" href="./resource/css/index.css">
	<link rel="stylesheet" href="./resource/css/user.css">
	<link rel="stylesheet" href="./resource/css/showBo.css">
</head>
<body>
<!-- 头部 -->
@include('common.index_head')
<!-- 个人中心 -->
<?php   $user  = UserService::instance()->GetUserInformation();?>
<div class="cont-user">
	<!-- 个人中心头部 -->
	@include('common.user_head')

	<div class="user-center">
		<div class="main">
			<!-- 个人中心列表 -->
			@include('common.user_left')
			
			<div class="user-container left" id="list">
				<div class="user-title user-bank">
					<div class="title">
						<div class="h left">银行卡管理</div>
					</div>

					<div class="user-box">
						@if(!empty($info))
							@foreach($info as $k=>$v)
							<div class="user-bor user-cade">
								<div class="bank-title">
									<span>{{$v->bank_name}}</span>
								</div>
								<input type="hidden"  id="bankid" value="{{$v->bank_id}}">
								<div class="user-mess">
									{{--<div class="span left">已绑定</div>--}}
									<div class="left cade">{{substr_replace($v->bank_num,'********',4,11)}}</div>
									<div class="span left clear">{{$v->bound_name}}</div>
									<div class="left"><span>{{date('Y-m-d',$v->created)}}</span></div>
								</div>
								<a href="/user_bankcard_up?bank_id={{$v->bank_id}}">编辑</a>
								<a href="javascript:;" class="delete a-cc"  data-bank_id="{{$v->bank_id}}">删除</a>
							</div>
							@endforeach
							@else
							<div class="user-bor user-add">
								<input type="hidden" value="{{$user->id_card}}" id="card">
								<div class="btn-b">
									<a href="javascript:void(0)" onclick="Certificate()"></a>
								</div>
								<span>添加银行卡</span>
							</div>
						@endif
					</div>

				</div>
			</div>
		</div>
	</div>
</div>

<div class="dvMsgBox">

		<div class="top">
			<div class="title">提示消息</div>
			<div class="close" id="btn-close"></div>
		</div>
		<div class="body">
			<div class="ct dvMsgCT">
				<input type="password" class="form-control" placeholder="请输入交易密码" id='pay_pwd'>
				<i></i>
				<span>交易密码输入错误</span>
				<div class="clear"></div>
			</div>
		</div>
		<div class="bottom">
			<div class="dvMsgBtns">
				<input type="submit" class="btn" value="确定删除" onclick="Checkbank()">
			</div>
		</div>

</div>
<div id="bank-bg"></div>

<!-- footer -->
@include('common.index_foot')
<script src="./resource/js/jquery-1.11.3.min.js"></script>
<script src="./resource/js/index.js"></script>
<script src="./resource/js/user.js"></script>
<script src="./resource/js/showBo.js"></script>
<!-- Datatables -->
<script src="resource/js/jquery.dataTables.js"></script>
<script src="resource/js/J_main.js"></script>
<script src="resource/js/T.js"></script>
<script type="text/javascript">
//	$(document).delegate('.delete','click',function(){
//		var data = $(this).data();
//		Showbo.Msg.confirm('您真的确定要删除吗？',function(s) {
//			if (s == 'yes') {
//				T.restPost('/user_bankcard_unbound', data, function (response) {
//					//console.log(response);
//					if (response.data.state) {
//						T.ajaxLoad('/bankcard_unbound_ajax', 'list', function () {
//						});
//					} else {
//						alert('删除失败');
//					}
//				});
//			}else{
//				return false;
//			}
//		})
//	});
	var $bankBg = $('#bank-bg');
	$bankBg.css({
		'width':$(document).width(),
		'height':$(document).height(),
		'position':'absolute',
		'background-color':'rgba(0,0,0,.3)',
		'left':'0',
		'top':'0',
		'z-index':'98',
		'display':'none',
	});
	$('.a-cc').click(function(){
		$('.dvMsgBox').show();
		$bankBg.show();
	});



	$('#btn-close').click(function(){
		$('.dvMsgBox').hide();
		$bankBg.hide();
	});
	function Certificate(){
		var card          = $('#card').val();
		if(card==''){
			Showbo.Msg.nameauth('请先完成实名认证，确保您账户安全',function(){
				window.location.href='/username_auth_one';
			})
			return false;
		}else{
			window.location.href='/user_bankcard_add';
			return false;
		}
	}


function  Checkbank(){
	var pay_pwd = $('#pay_pwd').val();
	var bank_id = $('#bankid').val();
	if(pay_pwd==''){
		$('.dvMsgCT span').show();
		return false;
	}
	$.ajax({
		url : '/user_bankcard_unbound',
		type : "POST",
		data : {pay_pwd:pay_pwd,bank_id:bank_id},
		dataType : "json",
		cache:"false",
		timeout:30000,
		success: function (json) {
			if (json.code == 1) {//ok
				$('.dvMsgCT span').show().html(json.mess);
				window.location.href="/user_bankcard";
				return false;
			} if (json.code == 2) {//ok
				$('.dvMsgCT span').show().html(json.mess);
				return false;
			}
		}

	});


}

</script>
</body>
</html>